<?php

class Auth extends CI_Controller {

	function __construct(){
		parent::__construct();
		
		$this->config->load('bf_auth');
		$this->load->library('BF_Auth');
		$this->load->library('Form_validation');
		
		$this->load->helper('form');
	}
	function index(){
		$this->login();
	}
	function login(){
				
		if(!$this->bf_auth->is_logged_in()):
			
			$this->form_validation->set_rules('bf_username', 'Username', 'trim|required|xss_clean');
			$this->form_validation->set_rules('bf_password', 'Password', 'trim|required|xss_clean');
								
			if($this->form_validation->run() && $this->bf_auth->login($this->form_validation->set_value('bf_username'),$this->form_validation->set_value('bf_password'))){
				redirect('backend');
			}else{
				$this->load->view($this->config->item('bf_login_view'));
			}
		else:
			redirect('backend');
		endif;
	}
	function logout(){
		echo 'logout';
		//$this->bf_auth->logout();
	}
}
